package com.lucy.common.converter;

import cn.hutool.core.convert.Convert;
import com.lucy.common.utils.JsonUtil;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import java.util.List;

/**
 * @author kindear
 * Jpa 通用@Column 转化器
 */
@Converter
public class JpaColumnConverter implements AttributeConverter<Object,String> {
    @Override
    public String convertToDatabaseColumn(Object o) {
        return JsonUtil.obj2String(o);
    }

    @Override
    public Object convertToEntityAttribute(String s) {
        return JsonUtil.string2Obj(s,Object.class);
    }
}
